<?php

/*@LICENSE@*/

require_once 'Clouseau/Genealogy/Tree/Exporter.php';

/**
 * An exporter for a genealogy tree to the DOT language.
 * @author Thomas Quémard <thomas.quemard@gmail.com>
 **/
class Clouseau_Genealogy_Tree_Exporter_Dot extends Clouseau_Genealogy_Tree_Exporter
{
	protected function _exportNode(Clouseau_Genealogy_Node &$oNode)
	{
		$s = '';
		foreach ($oNode as $oChild)
		{
			if (!is_null($oChild))
			{
				$s .= '   "' . $oNode->getName() . '" -- "' . $oChild->getName() . "\";\n";
				$s .= $this->_exportNode($oChild);
			}
		}
		return $s;
	}

	public function export(Clouseau_Genealogy &$oTree)
	{
		$s = "graph PhpClassGenealogyTree\n";
		$s .= "{\n";
		$s .= $this->_exportNode($oTree);
		$s .= "}";
		return $s;
	}
}
